# ============================================================
# by howlink *
# Filename       : createStandbyRedo.sh
#
# Description:  create dataguard primary standbyredo logfile 
# exmple: ./createStanbyRedo.sh  orcl orcl /u01/app/oradata/orcl 52428800
# =============================================================
#! /bin/sh
if [ $# -lt 2 ]; then
   exit 1
fi
sid=$1
instid=$2
logpath=$3
redosize=$4
spath=/opt/howlink/lb-agent/scripts/oracle/dg
redocount=`$spath/sqlplusShell.sh $spath/getRedocount.sql $1 $2`
stbredocount=`$spath/sqlplusShell.sh $spath/getStbRedocount.sql $1 $2`
if [ $redocount -lt $stbredocount ]; then
echo "standby_log is OK"
exit 0
fi
tmpn=$redocount+1
rm -rf $spath/tmp.sql
for ((i=1;i<=$tmpn;i++))
do
echo "ALTER DATABASE ADD STANDBY LOGFILE '$logpath/stbredo$i.log' size $redosize " >> $spath/tmp.sql
echo '/' >> $spath/tmp.sql
done
retval=`$spath/sqlplusShell.sh $spath/tmp.sql $1 $2`
export status=$retval
echo $retval
rm -rf $spath/tmp.sql
